﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace UsedBookTradeSystem.Migrations
{
    /// <inheritdoc />
    public partial class v106 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Books_BooksInfo_BookInfoId",
                table: "Books");

            migrationBuilder.AddColumn<bool>(
                name: "IsDisabled",
                table: "Users",
                type: "tinyint(1)",
                nullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "BookInfoId",
                table: "Books",
                type: "int",
                nullable: true,
                oldClrType: typeof(int),
                oldType: "int");

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "CreatedTime", "IsDisabled" },
                values: new object[] { new DateTime(2024, 4, 5, 15, 31, 32, 655, DateTimeKind.Local).AddTicks(4373), false });

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "Id",
                keyValue: 2,
                columns: new[] { "CreatedTime", "IsDisabled" },
                values: new object[] { new DateTime(2024, 4, 5, 15, 31, 32, 655, DateTimeKind.Local).AddTicks(4680), false });

            migrationBuilder.AddForeignKey(
                name: "FK_Books_BooksInfo_BookInfoId",
                table: "Books",
                column: "BookInfoId",
                principalTable: "BooksInfo",
                principalColumn: "Id");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Books_BooksInfo_BookInfoId",
                table: "Books");

            migrationBuilder.DropColumn(
                name: "IsDisabled",
                table: "Users");

            migrationBuilder.AlterColumn<int>(
                name: "BookInfoId",
                table: "Books",
                type: "int",
                nullable: false,
                defaultValue: 0,
                oldClrType: typeof(int),
                oldType: "int",
                oldNullable: true);

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "Id",
                keyValue: 1,
                column: "CreatedTime",
                value: new DateTime(2024, 4, 5, 14, 22, 29, 76, DateTimeKind.Local).AddTicks(179));

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "Id",
                keyValue: 2,
                column: "CreatedTime",
                value: new DateTime(2024, 4, 5, 14, 22, 29, 76, DateTimeKind.Local).AddTicks(448));

            migrationBuilder.AddForeignKey(
                name: "FK_Books_BooksInfo_BookInfoId",
                table: "Books",
                column: "BookInfoId",
                principalTable: "BooksInfo",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
